package com.quantdo.demo.action;

import org.eclipse.jface.action.Action;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;

import com.quantdo.demo.view.NavigatorView;

public class OpenNavigatorAction extends Action {

	private static final String NAVIGATOR_VIEW_ID = NavigatorView.class.getName();
	private final IWorkbenchWindow window;

	public OpenNavigatorAction(IWorkbenchWindow window) {
		System.out.printf("class:%s, function:%s() enter \n", OpenNavigatorAction.class, "OpenNavigatorAction");
		this.window = window;
		this.setText("&Navigator@Ctrl+N");
		setToolTipText("Open Navigator View");
	}

	@Override
	public void run() {
		System.out.printf("class:%s, function:%s() enter \n", OpenNavigatorAction.class, "run");
		if (null == window) return;
		try {
			window.getActivePage().showView(NAVIGATOR_VIEW_ID);
		} catch (PartInitException e) {
			e.printStackTrace();
			System.out.printf("文件不存在\n");
		}
	}

}
